//
//  YLLHomeCellViewModel.swift
//  YLLSina
//
//  Created by 于玲玲 on 16/8/1.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class YLLHomeCellViewModel: NSObject {

    var statusModel: YLLStatusModel?
    
    var screen_name: String?{
        
        return statusModel?.user?.screen_name
        
    }
    
    
    var photoUrl: NSURL?{
        
    return NSURL(string: statusModel?.user?.profile_image_url ?? "")

    }
    
    var verfited_Image: UIImage?{
        
        switch statusModel?.user?.verified_type ?? -1 {
        case -1: return UIImage()
        case 0: return UIImage(named: "avatar_vip")
        case 2,3,5: return UIImage(named: "avatar_enterprise_vip")
        case 220: return UIImage(named: "avatar_grassroot")
        default: return UIImage()
            
        }
        
        
    }
    
    var level_Image: UIImage?{
        
        if let num = statusModel?.user?.mbrank {
            return UIImage(named: "common_icon_membership_level\(num)")
        }else{
            return UIImage()
        }
        
        
    }
    
    var retweet_String: String?{
    
        if let count = statusModel?.reposts_count {
            
            if count > 0 {
                return "\(count)"
            }else{
                return "转发"
            }
            
        }else{
            return "转发"
        }
    
    }
    
    var source: String?{
        
        if let fromString = statusModel?.source{
            if fromString != "" {
                let subString = (fromString as NSString).componentsSeparatedByString("</").first
                let subS = (subString! as NSString).componentsSeparatedByString(">").last
                
                return "来自 "+subS!
            }
                return ""
        }
            return ""
    }
}
